from flask import Blueprint
from flask_restful import Api
from comment.utils.output import output_json

transaction_bp = Blueprint('transaction', __name__, url_prefix='/transaction')  # 创建蓝图
transaction_api = Api(transaction_bp)  # 创建蓝图中的资源API

# 使用我们自定义json格式，替代装饰器的写法
transaction_api.representation('application/json')(output_json)

# 加载当前模块的资源
from financial.resources.transaction.invest_resource import Invest_Resource
from financial.resources.transaction.deal_record_resource import Deal_Resource
from financial.resources.transaction.loan_resource import LoanApply
from financial.resources.transaction.debt_resource import Debt
from financial.resources.transaction.loan_resource import MyLoanApply
from financial.resources.transaction.debt_repay_resource import RepayPlan
from financial.resources.transaction.match_resource import MatchUp
from financial.resources.transaction.expectedReturn_resource import ExpectedReturnResource
from financial.resources.transaction.allMatched_resource import AllMatchedResource
from financial.resources.transaction.investIncome_resource import InvestIncomeResource
from financial.resources.transaction.matched_result_resource import MatchedResultResource

transaction_api.add_resource(Invest_Resource, '/invest_record', endpoint='invest_record')   # 查询投资记录
transaction_api.add_resource(Deal_Resource, '/deal_record', endpoint='deal_record')  # 交易记录
transaction_api.add_resource(LoanApply, '/loanApply', endpoint='loanApply')  # 借款申请
transaction_api.add_resource(MyLoanApply, '/myLoan', endpoint='myLoan')  # 我的借款
transaction_api.add_resource(Debt, '/debt', endpoint='debt')    # 债权
transaction_api.add_resource(RepayPlan, '/RepayPlan', endpoint='RepayPlan')  # 还款计划
transaction_api.add_resource(Invest_Resource, '/invest', endpoint='invest')  # 投资(购买理财产品)
transaction_api.add_resource(MatchUp, '/matchUp', endpoint='matchUp')   # 撮合匹配
transaction_api.add_resource(ExpectedReturnResource, '/exceptedReturn', endpoint='exceptedReturn')  # 预期收益
transaction_api.add_resource(AllMatchedResource, '/fundsNotMatched', endpoint='AllMatchedResource')    # 未匹配资金
transaction_api.add_resource(InvestIncomeResource, '/getIncome', endpoint='getIncome')  # 获取收益
transaction_api.add_resource(MatchedResultResource, '/matchedResult', endpoint='matchedResult')  # 匹配结果
